package com.shd.edanpei.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseActivity;
import com.shd.edanpei.presenter.contract.NewDemandContract;
import com.shd.edanpei.presenter.NewDemandPresenter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by mc on 2018/10/18.
 * yang-wen-wen
 */

public class NewDemandActivity extends BaseActivity<NewDemandPresenter> implements NewDemandContract.NewDemandIView {

    @BindView(R.id.headline)
    TextView headline;
    @BindView(R.id.tv_industry)
    TextView tvIndustry;
    @BindView(R.id.tv_needProduct)
    TextView tvNeedProdcut;
    @BindView(R.id.et_describe)
    EditText etDescribe;
    @BindView(R.id.submit)
    TextView tvSubmit;


    @Override
    protected int setLayout() {
        return R.layout.activity_new_demand;
    }

    @Override
    protected NewDemandPresenter bindPresenter() {
        return new NewDemandPresenter(this);
    }

    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {
        headline.setText("新增需求");
    }

    @Override
    protected void initListener() {
        etDescribe.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                mPresenter.setDescribe(s.toString());
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }

    @OnClick(R.id.iv_headline_back)
    void onBack(){
        finish();
    }

    @OnClick(R.id.ll_industry)
    void onIndustry() {
        mPresenter.onIndustry();
    }

    @OnClick(R.id.ll_needProduct)
    void onNeedProduct() {
        mPresenter.onNeedProduct();
    }

    @OnClick(R.id.submit)
    void onSubmit() {
        mPresenter.submit();
    }

    @Override
    public void setIndustry(String str) {
        tvIndustry.setText(str);
        tvIndustry.setTextColor(getResources().getColor(R.color.black));
    }

    @Override
    public void setDesc(String str) {
        etDescribe.setHint(str);
    }

    @Override
    public void setNeedProduct(String str) {
        tvNeedProdcut.setText(str);
        tvNeedProdcut.setTextColor(getResources().getColor(R.color.black));
    }

    @Override
    public void setDescribe(String str) {
        etDescribe.setText(str);
    }

    @Override
    public TextView getSubmitView() {
        return tvSubmit;
    }
}
